package org.ax.controller.plan;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.ax.data.Result;
import org.ax.pojo.plan.Custom;
import org.ax.pojo.sys.User;
import org.ax.service.plan.CustomService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;

/**
 * 编程人:赵浩鑫
 * 时间:2021-02-25-14:48
 */
@RestController
@RequestMapping("/custom")
public class CustomController {
    @RequestMapping("find")
    public ModelAndView find(){
        return new ModelAndView("plan/custom");
    }
    @Autowired
    CustomService customService;
    @Autowired
    Result result;
    @GetMapping("/list")
    public Result search(String customName,String status, @RequestParam(defaultValue = "1") int page, @RequestParam(defaultValue = "6") int limit){
        Page<Custom> customList = customService.findCustomList(new Page(page, limit), customName, status);
        result.setData(customList.getRecords());
        result.setCount(customList.getTotal());
        return result;
    }
    @PostMapping("/addCustom")
    public Result addCustom(Custom custom){
        result.setMsg(customService.addCustom(custom)?"添加成功":"添加失败");
        return result;

    }
    @PostMapping("/updateCustom")
    public Result updateCustom(Custom custom){
        result.setMsg(customService.updateCustom(custom)?"修改成功":"修改失败");
        return result;

    }
    @GetMapping("/patchDel")
    public Result patchDel(String[] customId){
        result.setMsg(customService.deletesCustom(customId)?"批量删除成功":"批量删除失败");
        return result;
    }


}
